<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;
use think\Cache;

class Member extends CrmController
{
    /**
     * memberLevel
     */
    public function memberLevel()
    {
        $menuname = "Member Level";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('memberLevel');
    }


    /**
     * 加载会员等级数据
     * @return json 会员等级数据
     */
    public function memberLevelData()
    {
        $arrData = Loader::model('Member')->memberLevelData();
        echo json_encode($arrData);
    }


    /**
     * 渲染模板addSystemSet
     */
    public function addMemberLevel()
    {
        $menuname = "Member Level";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('addMemberLevel');
    }


    /**
     * 新增会员等级
     */
    public function insertMemberLevel ()
    {
        $data = $_REQUEST;
        Loader::model('Member')->insertMemberLevel($data);
    }


    /**
     * 删除会员等级
     */
    public function delMemberLevel ()
    {
        $id = $_REQUEST['id'];
        Loader::model('Member')->delMemberLevel($id);
    }


    /**
     * 渲染模板editIllness
     */
    public function editMemberLevel()
    {
        $menuname = "Member Level";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);
        $id = $_GET['id'];
        $data = Loader::model('Member')->getMemberLevel($id);
        $str = '';
        $str .= "<option value='1' ".($data['groups']==1?'selected':'').">a类客户</option>";
        $str .= "<option value='2' ".($data['groups']==2?'selected':'').">b类客户</option>";
        $str .= "<option value='3' ".($data['groups']==3?'selected':'').">c类客户</option>";
        $str .= "<option value='4' ".($data['groups']==4?'selected':'').">d类客户</option>";
        $str .= "<option value='5' ".($data['groups']==5?'selected':'').">e类客户</option>";
        $str .= "<option value='6' ".($data['groups']==6?'selected':'').">不成单</option>";
        $data['option'] = $str;
        $this->assign('data', $data);
        // 模板输出
        return $this->fetch('editMemberLevel');
    }


    /**
     * 编辑会员等级
     */
    public function updateMemberLevel ()
    {
        $data = $_REQUEST;
        Loader::model('Member')->updateMemberLevel($data);
    }



}